Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Conversation

@kwen2501
Copy link
Contributor

@kwen2501 kwen2501 commented Sep 28, 2024

Change 1

Changing from:

    with device:
        model = Transformer(config)

to

    with torch.device("meta"):
        model = Transformer(config)

because when we later load weights, we will swap out the tensors of the model anyway. So saving an on-device init here.

Change 2

Also added a with device context to model.setup_cache() call. So that the caches are directly created on the target device -- saving a model.to(device) call.

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchchat/1227

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit cb77ba5 with merge base 77bac00 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 28, 2024
@kwen2501 kwen2501 requested a review from lessw2020 September 28, 2024 08:24
@metascroy
Copy link
Contributor

Rebase to fix failing tochao_experimental check

Copy link
Contributor

@lessw2020 lessw2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!
Tested with both llama2 and llama3.

@kwen2501 kwen2501 changed the base branch from pin_torch to main October 2, 2024 19:30
@kwen2501 kwen2501 merged commit 8fcb3ba into main Oct 2, 2024
52 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants